package bit.project.exception;

import bit.project.common.AppResult;
import bit.project.common.ResultCode;

public class ApplicationException extends RuntimeException{
    //自定义异常信息
    private AppResult errorResult;

    public ApplicationException(AppResult appResult) {
        //构造异常的message属性
        super(appResult.getMessage());
        //自定义错误描述
        this.errorResult = appResult;
    }

    public ApplicationException(String message) {
        super(message);
        //根据异常描述构建返回对象
        this.errorResult = new AppResult(ResultCode.FAILED.getCode(),message);
    }
    // 指定异常
    public ApplicationException(Throwable cause) {
        super(cause);
    }
    // ⾃定义异常描述，异常信息
    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }



    public void setErrorResult(AppResult errorResult) {
        this.errorResult = errorResult;
    }

    public AppResult getErrorResult() {
        return errorResult;
    }
}
